﻿using System.Windows;

namespace MvvmEx.Helpers
{
    /// <summary>
    /// 因为ContextMenu不会集成父级的DataContext，所以绑定方法很特殊
    /// 用于ContextMenu的绑定，例如
    /// DataContext="{Binding Source={StaticResource BindingProxy},Path=Data}"
    /// </summary>
    public class BindingHelper : Freezable
    {
        #region Overrides of Freezable

        protected override Freezable CreateInstanceCore()
        {
            return new BindingHelper();
        }

        #endregion

        public object Data
        {
            get { return (object)GetValue(DataProperty); }
            set { SetValue(DataProperty, value); }
        }

        public static readonly DependencyProperty DataProperty =
            DependencyProperty.Register("Data", typeof(object), typeof(BindingHelper), new UIPropertyMetadata(null));
    }
}